<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // function Person(name) {
        //     // this.name = name;
        // }
        // Person.prototype.getName = function() {
        //     console.log(this.name)
        // }

        // function Ma() {}


        /**
         * 原型继承
         */
        // Ma.prototype = new Person("mamama")
        // console.log(Ma.prototype)

        // // 父的原型上加一个元素，所有子都会加上
        // Person.prototype.eat = function() {
        //     console.log('eat')
        // }

        /**
         * 构造函数继承
         */
        // function Guo(name) {
        //     Person.call(this, name) // 只是借用一下父的方法
        // }
        // Guo('guoguo')
        // console.log(name)


        /**
         * 组合继承
         */
        // function inherits(ctor, spuerCtor) {
        //     ctor._super = spuerCtor;
        //     ctor.prototype = Object.create(spuerCtor.prototype, {
        //         consturctot: {
        //             value: ctor,
        //             writable: true,
        //             enumerable: false,
        //             configurable: true
        //         }
        //     })
        // }

        // // 使用
        // function Man() {
        //     Person.call(this)
        // }
        // inherits(Man, Person);
        // console.log(Man.prototype);


        // function Man2() {
        //     Person.call(this)
        // }
        // Man2.prototype = new Person();
        // Man2.prototype.constructor = Man2;
        // console.log(Man2.prototype)


        var nickname = "LiLei";
        function Person(name) {
            this.nickname = name;
            this.sayHi = function () {
                console.log(this.nickname)
            }
            setTimeout(function () {
                console.log(this.nickname)
            }, 0)
        }
        var Male = {
            nickname: "xiaofang",
            sayHi: () => {
                console.log(this.nickname)
            }
        }
        var person = new (Person.bind(Male, 'XiaoHong'));
        person.sayHi()
        console.log(Male.sayHi)
    </script>
</body>

</html>